package com.yeyks.app.controller.base.hotel;

import com.github.pagehelper.PageInfo;
import com.yeyks.common.ajax.AjaxResponseBody;
import com.yeyks.common.convert.DateEditor;
import com.yeyks.commonReference.service.hotel.HotelSearchJipService;
import com.yeyks.hotel.dto.HotelInfoC2bHotelVipSearchDto;
import com.yeyks.hotel.param.HotelInfoC2bHotelVipSearchParam;
import com.yeyks.hotel.param.HotelInfoHotelSearchOrderHotelInfoParam;
import com.yeyks.hotel.vo.HotelSearchJipSelectRoomCalendarVipInfoForOrderVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * @Author fuchangshuai
 * @date 2019/3/26 4:27 PM
 */
@Api(tags = "酒店搜索精选接口", description = "酒店搜索精选接口")
@Slf4j
@RestController
@RequestMapping(value = "/app/hotel/jip")
public class HotelSearchJipController {

    @Autowired
    private HotelSearchJipService hotelSearchJipService;

    @InitBinder
    public void initbinder(WebDataBinder webDataBinder) {
        webDataBinder.registerCustomEditor(Date.class, new DateEditor());
    }

    @ApiOperation(value = "jip酒店搜索:v3.5")
    @RequestMapping(value = "/hotelSearch", method = RequestMethod.POST)
    public AjaxResponseBody<PageInfo<HotelInfoC2bHotelVipSearchDto>> hotelSearch(@Validated HotelInfoC2bHotelVipSearchParam param) {
        PageInfo<HotelInfoC2bHotelVipSearchDto> listAjaxResponseBody = hotelSearchJipService.hotelSearch(param);
        return AjaxResponseBody.success(listAjaxResponseBody);
    }

    @ApiOperation(value = "jip订单房态信息:v3.5")
    @RequestMapping(value = "/selectRoomCalendarVipInfoForOrder", method = RequestMethod.POST)
    public AjaxResponseBody<HotelSearchJipSelectRoomCalendarVipInfoForOrderVo> selectRoomCalendarVipInfoForOrder(@Validated HotelInfoHotelSearchOrderHotelInfoParam param) {
        HotelSearchJipSelectRoomCalendarVipInfoForOrderVo vo = hotelSearchJipService.selectRoomCalendarVipInfoForOrder(param);
        return AjaxResponseBody.success(vo);
    }

}
